package com.m4f.business.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.jdo.annotations.NotPersistent;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.jdo.annotations.Unique;

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true")
public class GlobalConfiguration implements Serializable {
	
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long id;
	@Persistent
	private Long stage;
	@Persistent
	private Integer maxVotes;
	@Persistent
	private String version;
	@Persistent
	private String adminMail;
	@NotPersistent
	private List<BestPracticeType> bestPracticeTypes = new ArrayList<BestPracticeType>();
	@NotPersistent
	private List<SICCodeType> sICCodeTypes = new ArrayList<SICCodeType>();
	
	public GlobalConfiguration(Map<Long, String> innoTypes, 
			Map<String, String> scT, String version, Long stage, 
			Integer maxVotes, String adminEmail) {
		BestPracticeType bType;
		for(Long code : innoTypes.keySet()) {
			bType = new BestPracticeType(code, innoTypes.get(code));
			this.bestPracticeTypes.add(bType);
		}
		SICCodeType sicCode;
		for(String code : scT.keySet()) {
			sicCode = new SICCodeType(code, scT.get(code));
			this.sICCodeTypes.add(sicCode);
		}
		this.version = version;
		this.stage = stage;
		this.maxVotes = maxVotes;
		this.adminMail = adminEmail;
	}
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getStage() {
		return stage;
	}

	public void setStage(Long stage) {
		this.stage = stage;
	}

	public void setMaxVotes(Integer maxVotes) {
		this.maxVotes = maxVotes;
	}

	public Integer getMaxVotes() {
		return maxVotes;
	}

	public void setVersion(String version) {
		this.version = version;
	}

	public String getVersion() {
		return version;
	}

	public void setAdminMail(String adminMail) {
		this.adminMail = adminMail;
	}

	public String getAdminMail() {
		return adminMail;
	}
	
	public List<BestPracticeType> getBestPracticeTypes() {
		return this.bestPracticeTypes;
	}
	
	public void setBestPracticeTypes(List<BestPracticeType> types) {
		this.bestPracticeTypes = types;
	}
	
	public  List<SICCodeType> getSICCodeTypes() {
		return this.sICCodeTypes;
	}
	
	public void setSICCodeTypes(List<SICCodeType> scT) {
		this.sICCodeTypes = scT;
	}
}